<%--
新增退费项页面
@author <a href="mailto:chenfenghai@ceopen.cn">chenfenghai</a>
action ：cashieringAction
method ：initRefundAdd
created ：2010-10-26
--%>
<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/commonList.jsp"%>
<%@ include file="/commons/validation.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="${ctx}/scripts/div/common.js"></script>
<script type="text/javascript" src="${ctx}/scripts/public.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common/prototype.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script type="text/javascript" src="${ctx}/scripts/ajaxException.js"></script>
<script type="text/javascript" src="${ctx}/scripts/tags/unitedselect/UnitedSelect.js"></script>
<script type="text/javascript" src="${ctx}/scripts/Decimal.js"></script>
<title></title>
</head>
<script type="text/javascript">
	//房间改变时改变房号
	function houseOnchange(){
		$('houseNumber').value = $('houseId').options[$('houseId').selectedIndex].text;
		var temphouseId = $('houseId').options[$('houseId').selectedIndex].value;
		var url ="${ctx}/charge_cashieringAction.do?method=unitedSelect&houseId="+temphouseId+"&selectId="+temphouseId+"&targetId=chargeItemId";
		onChangeSelect(url,temphouseId,'itemId');
	}
	//退费项目改变时改变项目名称
	function itemOnChange(){
		$('itemName').value = $('itemId').options[$('itemId').selectedIndex].text;
		$('baseFee').value = "";
		$('lateFee').value = "";
		$('totalFee').value = "";
		//验证是否存在滞纳金
		var url="${ctx}/charge_cashieringAction.do?method=validateChargeItemLateFee&houseId="+$('houseId').options[$('houseId').selectedIndex].value+"&chargeItemId="+$('itemId').options[$('itemId').selectedIndex].value;
		new Ajax.Request(url,{method: 'post',parameters :{} ,onSuccess : lateFeeHandler});
	}
	//验证是否存在滞纳金后返回处理
	function lateFeeHandler(response){
		ajaxSubmitException(response.responseText);
		if("true" == response.responseText){
			$('lateFee').disabled = false;
		}else{
			$('lateFee').disabled = true;
		}
	}
	//计算合计
	function calculate(){
		if($('baseFee').value && $('lateFee').value){
			$('totalFee').value = new Decimal($('baseFee').value).add($('lateFee').value);
		}else if($('baseFee').value){
			$('totalFee').value = $('baseFee').value;
		}else if($('lateFee').value){
			$('totalFee').value = $('lateFee').value;
		}else{
			$('totalFee').value = "";
		}
	}
	//提交表单
	function refundSubmit(){
		var isTrue=$('refundForm').fireEvent("onSubmit") ;
		//验证不通过
	    if(!isTrue){
		    return;
	    }
        var param = Form.serialize('refundForm');
        new Ajax.Request($('refundForm').action,{method: 'post',parameters :param ,onSuccess : showResponse});
	}
	function showResponse(response){
		if("same" == response.responseText){
			ErrorAlert("本项目已经添加，不得再次添加！");
		}else if("true" == response.responseText){
			findFrame('refundList').parent.reloadRefunds();
			windowClose();
		}
	}
</script>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td class="window_head_outBg">
		<table border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td><span class="window_head_intext"><img
					src="${ctx}/images/ico_Advance.gif" align="absmiddle" />&nbsp;添加</span></td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td class="aux_header_line_1"></td>
	</tr>
	<tr>
		<td class="aux_header_line_2"></td>
	</tr>
	<tr>
		<td>
		<form action="${ctx}/charge_cashieringAction.do?method=addRefundItem"
			name="refundForm" method="post" class="required-validate">
		<table width="100%" border="0" cellpadding="0" cellspacing="1">
			<tr>
				<td class="aux_intable_td1">房号：</td>
				<td class="aux_intable_td2"><select id="houseId"
					name="houseId" onchange="houseOnchange();" style="width: 110px;">
					<c:forEach items="${houseList}" var="house">
						<option value="${house.keyword}">${house.houseNumber }</option>
					</c:forEach>
				</select>
				<input type="hidden" id="houseNumber" name="houseNumber" value="${houseNumber }" /></td>
			</tr>
			<tr>
				<td class="aux_intable_td1">项目名称：</td>
				<td class="aux_intable_require"><pms:unitedSelect id="itemId" name="itemId"
					onChange="itemOnChange();"
					optionLabel="itemName" optionValue="keyword"
					className="select-one-required" selectText="请选择"
					dataList="${chargeItemList}" style="width:110px;" />
					<input type="hidden" id="itemName" name="itemName" />
					</td>
			</tr>
			<tr>
				<td class="aux_intable_td1">本金：</td>
				<td class="aux_intable_td2"><input type="text" id="baseFee" name="baseFee"
					class="float-zero-right integer-decimal-range-18-2" onblur="calculate();"
					style="text-align: right" value="" size="16" afterInsert="baseFeeTip"
					maxlength="11" />&nbsp;元<span id="baseFeeTip"></span></td>
			</tr>
			<tr>
				<td class="aux_intable_td1">滞纳金：</td>
				<td class="aux_intable_td2"><input type="text" id="lateFee" name="lateFee"
					class="float-zero-right integer-decimal-range-18-2" onblur="calculate();"
					style="text-align: right" size="16" afterInsert="lateFeeTip"
					maxlength="11" />&nbsp;元<span id="lateFeeTip"></span></td>
			</tr>
			<tr>
				<td class="aux_intable_td1">合计：</td>
				<td class="aux_intable_require"><input type="text" id="totalFee" name="totalFee"
					class="required float-right integer-decimal-range-18-2"
					style="text-align: right" size="16" afterInsert="totalFeeTip"
					readonly="readonly" />&nbsp;元<span id="totalFeeTip"></span></td>
			</tr>
		</table>
		</form>
		</td>
	</tr>
	<tr>
		<td colspan="2" class="window_footer">
		<table border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td>
				<table border="0" cellpadding="0" cellspacing="0"
					onclick="refundSubmit();">
					<tr>
						<td class="buttonOffLeft" id="btn1_21"></td>
						<td class="buttonOffMiddle" id="btn1_22"
							onMouseOver="btn_change_over(2)" onMouseOut="btn_change_out(2)"
							onblur="btn_change(2)"><img src="${ctx}/images/ico_ok.gif"
							alt="" width="14" height="14" border="0" align="absbottom" /> 确
						定</td>
						<td class="buttonOffRight" id="btn1_23"></td>
					</tr>
				</table>
				</td>
				<td class="btn_between_space"></td>
				<td>
				<table border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td class="buttonOffLeft" id="btn1_31"></td>
						<td class="buttonOffMiddle" id="btn1_32" onClick="windowClose();"
							onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)"
							onblur="btn_change(3)"><img
							src="${ctx}/images/ico_cancel.gif" alt="" width="14" height="14"
							border="0" align="absbottom" /> 关 闭</td>
						<td class="buttonOffRight" id="btn1_33"></td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		<p>&nbsp;</p>
		</td>
	</tr>
</table>
</body>
</html>